class Solution {
public:
    void constuct_paths(TreeNode* root, string path, vector<string>& paths)
    {
        if (root == NULL) return;

        path += to_string(root->val);
        if (root->left == nullptr && root->right == nullptr) paths.push_back(path);
        else {
            path += "->";
            constuct_paths(root->left, path, paths);
            constuct_paths(root->right, path, paths);

        }
    }
    vector<string> binaryTreePaths(TreeNode* root) {
        vector<string> paths;
        constuct_paths(root, "", paths);
        return paths;
    }
};